#include <iostream>

using namespace std;

void gen_kmp_next_vector(const char* str, unsigned int* next, unsigned int n)
{
    unsigned int i = 0;

    next[i] = 0;
    while(++i < n)
    {
        unsigned int k = next[i-1];

        while(k != 0 && str[k] != str[i])
            k = next[k-1];

        if (str[k] == str[i])
        {
            k += 1;
        }

        next[i] = k;
    }
}

int main(void)
{
    unsigned int n;
    unsigned int test_id = 0;
    char str[1000001];
    unsigned int next[1000000];

    while(cin>>n && n > 0)
    {
        test_id++;
        cin>>str;

        cout<<"Test case #"<<test_id<<endl;

        gen_kmp_next_vector(str, next, n);

        for(unsigned int i = 1; i < n; i++)
        {
            unsigned int prefix_len = i+1;
            unsigned int sub_prefix_len = prefix_len - next[i];

            if ((prefix_len % sub_prefix_len) == 0)
            {
                unsigned int k = prefix_len/sub_prefix_len;
                if (k > 1)
                {
                    cout<<prefix_len<<" "<<k<<endl;
                }
            }
        }

        cout<<endl;
    }

    return 0;
}
